// pages/me/me.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        name: '游客',
        avatarurl: ''
    },
    quanyizhongxin: function () {
        if (this.data.status) {
            wx.navigateTo({
                url: "/pages/quanyi/quanyi"
            })
        } else {
            this.shouquan()
        }

    },
    wodebaozhang: function () {
        if (this.data.status) {
            wx.navigateTo({
                url: "/pages/baozhang/baozhang"
            })
        } else {
            this.shouquan()
        }

    },
    wodefenxiao: function () {
        if (this.data.status) {
            wx.navigateTo({
                url: "/pages/fenxiao/fenxiao"
            })
        } else {
            this.shouquan()
        }
    },
    renzhengxinxi: function () {
        if (this.data.status) {
            wx.navigateTo({
                url: "/pages/renzheng/renzheng"
            })
        } else {
            this.shouquan()
        }
    },
    qianbao: function () {
        if (this.data.status) {
            wx.navigateTo({
                url: "/pages/qianbao/qianbao"
            })
        } else {
            this.shouquan()
        }
    },
    dingdan: function () {
        if (this.data.status) {
            wx.navigateTo({
                url: "/pages/dingdan/dingdan"
            })
        } else {
            this.shouquan()
        }

    },
    jiaocheng: function () {
        if (this.data.status) {
            wx.navigateTo({
                url: "/pages/jiaocheng/jiaocheng"
            })
        } else {
            this.shouquan()
        }


    },
    kefu: function () {
        // wx.navigateTo({
        //     url:"/pages/renzheng/renzheng"
        // })

    },
    guanyu: function () {
        if (this.data.status) {
            wx.navigateTo({
                url: "/pages/guanyu/guanyu"
            })
        } else {
            this.shouquan()
        }


    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.is_shouquan()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    is_shouquan: function () {
        var that = this
        wx.getSetting({
            success(res) {
                if (res.authSetting["scope.userInfo"]) {
                    that.setData({
                        status: true
                    })
                
                    wx.getUserInfo({
                        success: function (res) {
                            that.setData({
                                name: res.userInfo.nickName,
                                avatarurl: res.userInfo.avatarUrl
                            })
                        }
                    })

                } else {
                    that.setData({
                        status: false
                    })

                }
            }
        })
    },
    shouquan: function () {
        wx.navigateTo({
            url: '/pages/shouquan/shouquan',
        })
    },
    call_dh: function () {
        wx.makePhoneCall({
            phoneNumber: '4008635550' //仅为示例，并非真实的电话号码
        })
    }
})